package com.tungse.study.io.four;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class HandlerSocketServerPool {
    //创建线程池
    private ExecutorService executorService;

    //初始化线程池
    public HandlerSocketServerPool(int corePollSize, int maxPoolSize, int queueSize) {
        executorService = new ThreadPoolExecutor(corePollSize, maxPoolSize, 60L, TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(queueSize));


    }

    //提供一个接收任务给线程池的方法， 等待线程池处理

    public void execute(Runnable task) {
        executorService.execute(task);

    }

}
